package cn.keniykey.mc.landterritory.landflag;

import java.util.List;

import javax.annotation.Nullable;

import cn.keniykey.mc.landterritory.landflag.api.ELandFlagParType;
import cn.keniykey.mc.landterritory.landflag.api.ELandFlagType;

public abstract class LandFlag {
	String custom_name;
	List<String> custom_lore;
	LandFlagClassLoader loader;
	
	LandFlagDescription description;
	
	boolean bool_loaded = false;
	
	public abstract ELandFlagType getELandFlagType();
	public abstract ELandFlagParType getELandFlagParType();
	public boolean allowAllPlayerData() {
		switch(this.getELandFlagParType()) {
		case MUCH:
			return true;
		default:
		}
		return false;
	}
	public final void setDisplayName(String name) {
		this.custom_name = name;
	}
	public final String getDisplayName() {
		return (this.custom_name == null ? this.getName() : this.custom_name);
	}
	public final String getName() {
		return this.description.getName();
	}
	public final void setIntroductionLore(@Nullable List<String> lore) {
		this.custom_lore = lore;
	}
	@Nullable
	public final List<String> getIntroductionLore() {
		return this.custom_lore;
	}
	public final LandFlagDescription getDescription() {
		return this.description;
	}
	public final boolean isLoaded() {
		return this.bool_loaded;
	}
	
	@Override
	public String toString() {
		return this.getName();
	}
	@Override
	public int hashCode() {
		return this.description.hashCode();
	}
	@Override
	public boolean equals(Object obj) {
		if(obj == null) return false;
		if(obj == this) return true;
		if(!(obj instanceof LandFlag)) return false;
		final LandFlag flag = (LandFlag) obj;
		return this.getName().equals(flag.getName());
	}
	
	void init(LandFlagDescription des,LandFlagClassLoader loader) {
		this.description = des;
		this.loader = loader;
	}
}